<template>
  <div class="content">
    <workerlist :total="this.sum" :data="this.userList.slice((currentPage-1)*pagesize,currentPage*pagesize)"></workerlist>
  </div>
</template>

<script>
  export default {
    props: {
      transport_data: String
    },
    data() {
      return {
        userList: [],
        permission: this.$store.state.permission,
        currentPage: 1, //初始页
        pagesize: 6,
        sum:'',
      }
    },
    created() {
      this.loadUsers(1,6);
    },
    methods: {
      loadUsers(page,size) {
        if (this.permission == "超管") {
          this.$axios.get('/api/taoyun/v1/SAdmin/userManage/ShowAll', {
              params: {
                Id: this.$store.state.userId,
                page: page,
                size: size,
              },
            })
            .then(res => {
              this.userList = res.data.data.list;
              this.sum=res.data.data.total;
            })
            .catch(err => {
              console.log(err)
            })
        }
        if (this.permission == "管理员") {
          this.$axios.get('/api/taoyun/v1/Admin/userManage/ShowAllUserByDepart', {
              params: {
                Department: this.$store.state.department,
                page: page,
                size: size,
              },
            })
            .then(res => {
              this.userList = res.data.data.list;
              this.sum=res.data.data.total;
            })
            .catch(err => {
              console.log(err)
            })
        }
      },
      set_userlist(userList,sum) {
        this.userList = userList;
        this.sum=sum;
      }
    },
  };
</script>

<style>
</style>
